package com.neulogistics.contrib.procuredcenter.infrastructure.persistence.orm.po;

import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;

import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.Data;

/**
 * 采购单表
 * @TableName tb_purchase_order
 */
@TableName(value ="tb_purchase_order", autoResultMap = true)
@Data
public class PurchaseOrderPO implements Serializable {
    /**
     * 采购单id
     */
    @TableId(value = "purchase_order_id")
    private Long purchaseOrderId;

    /**
     * 采购单类型：0:进货；1:退货
     */
    @TableField(value = "purchase_type")
    private Integer purchaseType;

    /**
     * 关联中心库房id
     */
    @TableField(value = "warehouse_id")
    private Integer warehouseId;

    /**
     * 采购项，{商品id、数量、单价、计量单位、供应商}
     */
    @TableField(value = "purchase_item", typeHandler = JacksonTypeHandler.class)
    private JSONObject purchaseItem;

    /**
     * 采购单总计
     */
    @TableField(value = "purchase_total")
    private Integer purchaseTotal;

    /**
     * 生成时间
     */
    @TableField(value = "create_time")
    private Date createTime;

    /**
     * 是否删除
     */
    @TableField(value = "deleted")
    @TableLogic(value = "0", delval = "1")
    private Integer deleted;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        PurchaseOrderPO other = (PurchaseOrderPO) that;
        return (this.getPurchaseOrderId() == null ? other.getPurchaseOrderId() == null : this.getPurchaseOrderId().equals(other.getPurchaseOrderId()))
            && (this.getPurchaseType() == null ? other.getPurchaseType() == null : this.getPurchaseType().equals(other.getPurchaseType()))
            && (this.getWarehouseId() == null ? other.getWarehouseId() == null : this.getWarehouseId().equals(other.getWarehouseId()))
            && (this.getPurchaseItem() == null ? other.getPurchaseItem() == null : this.getPurchaseItem().equals(other.getPurchaseItem()))
            && (this.getPurchaseTotal() == null ? other.getPurchaseTotal() == null : this.getPurchaseTotal().equals(other.getPurchaseTotal()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
            && (this.getDeleted() == null ? other.getDeleted() == null : this.getDeleted().equals(other.getDeleted()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getPurchaseOrderId() == null) ? 0 : getPurchaseOrderId().hashCode());
        result = prime * result + ((getPurchaseType() == null) ? 0 : getPurchaseType().hashCode());
        result = prime * result + ((getWarehouseId() == null) ? 0 : getWarehouseId().hashCode());
        result = prime * result + ((getPurchaseItem() == null) ? 0 : getPurchaseItem().hashCode());
        result = prime * result + ((getPurchaseTotal() == null) ? 0 : getPurchaseTotal().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        result = prime * result + ((getDeleted() == null) ? 0 : getDeleted().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", purchaseOrderId=").append(purchaseOrderId);
        sb.append(", purchaseType=").append(purchaseType);
        sb.append(", warehouseId=").append(warehouseId);
        sb.append(", purchaseItem=").append(purchaseItem);
        sb.append(", purchaseTotal=").append(purchaseTotal);
        sb.append(", createTime=").append(createTime);
        sb.append(", deleted=").append(deleted);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}